#include<iostream>
using namespace std;

int getLCA(int a, int b) {
	int t1 = a, t2 = b;
	int m = 1, n = 1;
	while (t1 != 1)
	{
		m++;
		t1 /= 2;
	}
	while (t2 != 1)
	{
		n++;
		t2 /= 2;
	}
	int *p1 = (int*)calloc(m, sizeof(int));
	int *p2 = (int*)calloc(n, sizeof(int));
	for (int i = m; i>0; i--)
	{
		p1[i - 1] = a;
		a /= 2;
	}

	for (int i = n; i>0; i--)
	{
		p2[i - 1] = b;
		b /= 2;
	}
	for (int i = 0;; i++)
	{
		if (p1[i] != p2[i])
			return p1[i - 1];
	}
}
int main()
{
	int m, n;
	while (cin >> m >> n)
	{
		cout << getLCA(m, n);
	}
}